var ws, mid, physical, aid, name , sex, height, weight, age, marry, nation, phone, address, wtype;
document.addEventListener('plusready',function(){
	ws = plus.webview.currentWebview();
	mid = ws.mid;
	wtype = ws.wtype;
	console.log(mid+" "+wtype);
	showWating();
	console.log(apiRoot+"?m=home&c=member&a=means&mid="+mid); 
	$.ajax({
		type:"get",
		url:apiRoot+"?m=home&c=member&a=means&mid="+mid,
		dataType :'json',
		success :function(v){
			console.log(JSON.stringify(v)); 
			plus.nativeUI.closeWaiting();
			aid = v.aid;
			physical = v.physical;
			$('.name').val(v.name);
			name = v.name;
			$('.uploadPic').attr('src',getAvatar(v.avatar));
			$('.sex').val(v.sex);
			sex = v.sex;
			age = v.age;
			if(age != 0 && age){
				$('.age').val(v.age);
			}
			$('.height').val(v.height);
			height = v.height;
			$('.weight').val(v.weight);
			weight = v.weight;
			$('.marry').val(v.marry);
			marry = v.marry;
			$('.nation').val(v.nation);
			nation = v.nation;
			$('.phone').val(v.phone);
			phone = v.phone;
			$('.address').val(v.address);
			address = v.address;
			if(v.cases){
				$('.wubl').hide();
				var str2 = '';
				$.each(v.caselist, function(key1,value1) {
					str2 += '<div class="mui-table-view-cell mui-table-view case-list" bid="'+value1.aid+'">'+
								'<li>'+
									'<span>'+value1.aidsname+'</span>'+
									'<span class="mui-h6 mui-pull-right">'+value1.ztime+'</span>'+
								'</li>'+
								'<li class="font-12 line-h-25">'+value1.history+'</li>'+
							'</div>';
				});
				$('.youbl').html(str2);
				$('.case-list').on('click',function(){
					goNewPage('me-archives-home-case.html', {aid:$(this).attr('bid')})
				})
			}else{
				$('.wubl').show();
				$('.youbl').hide();
			}
		},
		error :function(e){
			console.log(JSON.stringify(e));
			errortoast();
		}
	});
	//自我检测
	$('.ziwotest').click(function(){
		console.log(physical);
		if(physical){//已有自我检测结果，直接显示
			goNewPage('me-family-inf.html', {physical:physical})
		}else{
			toast('暂无自我检测数据！');
		}
	})
	//添加病历单
	$('.doc-add-inf-btn').click(function(){//aid -> 病人Id
		goNewPage('free-information-order-add.html', {aid:aid,name:name,sex:sex, height:height,weight:weight,age:age,marry:marry,nation:nation,phone:phone,address:address,spage:ws.id,wtype:wtype})
	})
},false)
